<template>
    <el-dialog :visible.sync="visible" v-dialogDrag :title="title" :close-on-click-modal="false" class="tl-dialog" width="1200px" @open="open" @close="close">
        <el-form class="tl-form" ref="form" :model="model" :rules="rules" label-width="120px" :disabled="disableEditSubmit">
            <el-row>
                <el-col :span="12">
                    <el-form-item label="对应部门" prop="deptname" :rules="rules.validateRequire">
                        <tl-ref-dept v-model="model.deptname" :initDisplayData.sync="model.deptname" dataType="code" nameType="fullname" @confirm="onSelectDept" :singleSelect="true"></tl-ref-dept>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="对应部门编码" prop="deptcode">
                        <el-input v-model="model.deptcode" :readonly="true" class="is-disabled"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="合同审核人" prop="contractusername" :rules="rules.validateRequire">
                        <tl-ref-user v-model="model.contractusername" :initDisplayData.sync="model.contractusername" dataType="code" :singleSelect="true" @confirm="onSelectUserContract"></tl-ref-user>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="合同审核人工号" prop="contractusercode">
                        <el-input v-model="model.contractusercode" :readonly="true" class="is-disabled"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="开票转单人" prop="invoiceerpusername" :rules="rules.validateRequire">
                        <tl-ref-user v-model="model.invoiceerpusername" :initDisplayData.sync="model.invoiceerpusername" dataType="code" :singleSelect="true" @confirm="onSelectUserInvoiceErp"></tl-ref-user>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="开票转单人工号" prop="invoiceerpusercode">
                        <el-input v-model="model.invoiceerpusercode" :readonly="true" class="is-disabled"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <!-- <el-row>
                <el-col :span="12">
                    <el-form-item label="开票办理人" prop="invoiceusername" :rules="rules.validateRequire">
                        <tl-ref-user v-model="model.invoiceusername" :initDisplayData.sync="model.invoiceusername" dataType="code" :singleSelect="true" @confirm="onSelectUserInvoice"></tl-ref-user>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="开票办理人工号" prop="invoiceusercode">
                        <el-input v-model="model.invoiceusercode" :readonly="true" class="is-disabled"></el-input>
                    </el-form-item>
                </el-col>
            </el-row> -->
            <el-row>
                <el-col :span="24">
                    <el-form-item label="备注" prop="description">
                        <el-input v-model="model.description" type="textarea" :rows="4"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button :type="disableEditSubmit === false ? 'text' : 'primary'" @click="doCancelEdit">取消</el-button>
            <el-button type="primary" @click="doSubmitEdit" :loading="saveLoading" v-if="disableEditSubmit === false">确认</el-button>
        </div>
    </el-dialog>
</template>

<script>
/** mixins */
import { mixin_edit } from '@tapui/mixins/mixin_edit'
/** 子组件 */
/** 工具类 */
import { putAction, getAction, postAction, deleteAction } from '@tapui/utils/http'
/** VUE配置 */
export default {
    mixins: [mixin_edit],
    components: {},
    data() {
        return {
            moduleTitle: '待办人员档案',
            urlPrefix: '/pm/deal/',
            url: {
                // 额外的url
            }
        }
    },
    methods: {
        loaded() {
            // 页面加载完毕执行
        },
        onSelectDept(selectedDepts) {
            const selectedDept = selectedDepts[0]
            this.$set(this.model, 'deptname', selectedDept.fullname)
            this.$set(this.model, 'deptcode', selectedDept.code)
        },
        onSelectUserContract(selectedUsers) {
            const selectedUser = selectedUsers[0]
            const { code, name } = selectedUser
            this.$set(this.model, 'contractusercode', code)
            this.$set(this.model, 'contractusername', name)
        },
        onSelectUserInvoiceErp(selectedUsers) {
            const selectedUser = selectedUsers[0]
            const { code, name } = selectedUser
            this.$set(this.model, 'invoiceerpusercode', code)
            this.$set(this.model, 'invoiceerpusername', name)
        },
        onSelectUserInvoice(selectedUsers) {
            const selectedUser = selectedUsers[0]
            const { code, name } = selectedUser
            this.$set(this.model, 'invoiceusercode', code)
            this.$set(this.model, 'invoiceusername', name)
        }
    }
}
</script>

